# -*- coding: utf-8 -*-
# @Author	: starview.brotherbaby
# @Date		: 2024/1/4 10:11
# @Last Modified by:   starview.brotherbaby
# @Last Modified time: 2024/1/4 10:11
# Thanks for your comments!

from sqlalchemy import Column, Integer, VARCHAR, ForeignKey, BigInteger

from src.consts import ModelName
from src.db_proxy.models.modelbase import ModelBase, ModifyingBehevior
from src.db_proxy.models.order import Order


class Operation(ModelBase, ModifyingBehevior):
    __tablename__ = ModelName.Operation.value

    id = Column('id', Integer, primary_key=True, autoincrement=True)
    order_id = Column('order_id', Integer, ForeignKey(Order.__tablename__ + '.' + Order.id.name), index=True)
    shoes_ecode = Column('shoes_ecode', VARCHAR(64), index=True)  # 鞋子编码
    operation_type = Column('operation_type', Integer, default=0)  # 0提交，7收件，1入厂，2出厂，3退回，4接收配送，5完成
    operation_time = Column('operation_time', BigInteger)
    operator = Column('operator', VARCHAR(64))
    remark = Column('remark', VARCHAR(256))

    def get_fields(self):
        return {
            "id": self.id,
            "order_id": self.order_id,
            "shoes_ecode": self.shoes_ecode,
            "operation_type": self.operation_type,
            "operation_time": self.operation_time,
            "operator": self.operator,
            "remark": self.remark
        }
